package com.teamblueplus;

import com.teamblueplus.comicmaker.ComicMaker;
import com.teamblueplus.viewcomic.ViewComicFlipperStyle;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * ComicComicActivity is the starting activity of the project
 */
public class ComicComicActivity extends Activity implements OnClickListener {

	// variables
	private Button comicMakerButton;
	private Button viewComicButton;

	private Button exitButton;
	private Intent myIntent;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		comicMakerButton = (Button) findViewById(R.id.bComicMaker);
		viewComicButton = (Button) findViewById(R.id.bViewComic);
		exitButton = (Button) findViewById(R.id.bExit);

		comicMakerButton.setOnClickListener(this);

		viewComicButton.setOnClickListener(this);
		exitButton.setOnClickListener(this);

	}

	@Override
	/**
	 * Start an event when user clicked on the button
	 */
	public void onClick(View v) {
		switch (v.getId()) {

		case R.id.bComicMaker: // start comic maker
			myIntent = new Intent(ComicComicActivity.this, ComicMaker.class);
			ComicComicActivity.this.startActivity(myIntent);
			break;

		case R.id.bViewComic:
			myIntent = new Intent(ComicComicActivity.this, ViewComicFlipperStyle.class);
			ComicComicActivity.this.startActivity(myIntent);
			break;

		case R.id.bExit: // exit the activity
			this.finish();
			this.onDestroy();
			System.exit(1);
			break;
		}
	}
}